import axios from 'axios'

axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8';

const service = axios.create()

// 请求拦截器
service.interceptors.request.use(req => {
    //判断缓存的过期文件
    req.headers['Cache-Control'] = 'no-cache'
    return req
}, error => {
    Promise.reject(error)
})

//响应拦截器
service.interceptors.response.use(res => {
    if(res.request.responseType === 'blob'){
        return res.data
    }
    return res.data
},error => {
    return Promise.reject(error)
})

export default service;